import React, { useContext, useEffect } from 'react';
import { Context } from '@/store/context';
import Card from '@/components/Card';
import ConsList from '@/components/List/Today';
import NumList from '@/components/NumList';
// import { getData } from '@/utils/commonApi';
import { api } from '@/utils/http';
import { JUHE_APPKEY } from '@/config/key';

export default function Today() {
    const {state, dispatch} = useContext(Context);
    // console.log('子页面里面用state：', state);

    const getData = async () => {
        const res = await api(`/api/constellation/getAll?consName=${state.consName}&type=${state.filed}&key=${JUHE_APPKEY}`);
        console.log(res);
    }

    useEffect(() => {
        // getData(state.consName, state.filed)
        getData();
    }, []);

    return (
        <div>
            <Card
                name={state.today.name}
                allIndex={10}
            />
            <NumList 
                data={state.today}
            />
            <ConsList 
                data={state.today}
            />
        </div>
    )
}